import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)
// console.log(process.env.NODE_ENV)
// console.log(_import)
// console.log(_import('login/index'))
// var dataName = i18n.messaproductPriceges[i18n.locale]
/**
 * icon : the icon show in the sidebar
 * hidden : if `hidden:true` will not show in the sidebar
 * redirect : if `redirect:noredirect` will no't redirct in the levelbar
 * noDropdown : if `noDropdown:true` will not has submenu in the sidebar
 * meta : `{ role: ['admin'] }`  will control the page role
 **/
export const constantRouterMap = [
  {
    path: '/login',
    name: 'login',
    component: _import('login/index'),
    hidden: true
  },
  {
    path: '/signUp',
    name: 'signUp',
    component: _import('signUp/index'),
    hidden: true
  },
  {
    path: '/404',
    name: '404',
    component: _import('404'),
    hidden: true
  }
]

export const asyncRouterMap = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'dashboard',
    hidden: true
  },
  {
    path: '/dashboard',
    component: Layout,
    name: '首页',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('dashboard/index'),
        name: '首页'
      }
    ]
  },
  {
    path: '/subjectOverview',
    component: Layout,
    name: '学科概况',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('subjectOverview/index'),
        name: '学科简介',
        children: [
          {
            path: '/subjectOverview/synopsisList',
            component: _import('subjectOverview/components/synopsisList'),
            name: '课程资源列表'
          },
          {
            path: '/subjectOverview/synopsis',
            component: _import('subjectOverview/components/synopsis'),
            name: '课程资源'
          },
          {
            path: '/subjectOverview/situationList',
            component: _import('subjectOverview/components/situationList'),
            name: '电子图书列表'
          },
          {
            path: '/subjectOverview/situation',
            component: _import('subjectOverview/components/situation'),
            name: '电子图书'
          },
          {
            path: '/subjectOverview/goalProgrammingList',
            component: _import('subjectOverview/components/goalProgrammingList'),
            name: '课程简介列表'
          },
          {
            path: '/subjectOverview/goalProgramming',
            component: _import('subjectOverview/components/goalProgramming'),
            name: '课程简介'
          }
        ]
      }
    ]
  },
  {
    path: '/courseNews',
    component: Layout,
    name: '学科新闻',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('courseNews/index'),
        name: '学科新闻',
        children: [
          {
            path: '/courseNews/courseNewsList',
            component: _import('courseNews/components/courseNewsList'),
            name: '学科新闻列表'
          },
          {
            path: '/courseNews/newsDetails',
            component: _import('courseNews/components/newsDetails'),
            name: '学科新闻详情'
          }
        ]
      }
    ]
  },
  {
    path: '/announcement',
    component: Layout,
    name: '公告',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('announcement/index'),
        name: '公告',
        children: [
          {
            path: '/announcement/announcementList',
            component: _import('announcement/components/announcementList'),
            name: '公告列表'
          },
          {
            path: '/announcement/announcementDetails',
            component: _import('announcement/components/announcementDetails'),
            name: '公告详情'
          }
        ]
      }
    ]
  },
  {
    path: '/links',
    component: Layout,
    name: '友情链接',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('links/index'),
        name: '友情链接'
      }
    ]
  },
  {
    path: '/generalSituation',
    component: Layout,
    name: '学科资源',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('generalSituation/index'),
        name: '学科资源',
        children: [
          {
            path: '/generalSituation/course',
            component: _import('generalSituation/components/course'),
            name: '课程资源'
          },
          {
            path: '/generalSituation/courseList',
            component: _import('generalSituation/components/courseList'),
            name: '课程资源列表'
          },
          {
            path: '/generalSituation/netLibrary',
            component: _import('generalSituation/components/netLibrary'),
            name: '电子图书'
          },
          {
            path: '/generalSituation/netLibraryDetail',
            component: _import('generalSituation/components/netLibraryDetail'),
            name: '电子图书详情'
          },
          {
            path: '/generalSituation/introduction',
            component: _import('generalSituation/components/introduction'),
            name: '课程简介详情'
          },
          {
            path: '/generalSituation/introductionList',
            component: _import('generalSituation/components/introductionList'),
            name: '课程简介列表'
          }
        ]
      }
    ]
  },
  {
    path: '/onlineClass',
    component: Layout,
    name: '在线课堂',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('onlineClass/index'),
        name: '在线课堂',
        children: [
          {
            path: '/onlineClass/regulationsList',
            component: _import('onlineClass/components/regulationsList'),
            name: '在线课堂列表'
          },
          {
            path: '/onlineClass/regulations',
            component: _import('onlineClass/components/regulations'),
            name: '共同条令详情'
          }
        ]
      }
    ]
  },
  {
    path: '/talentCultivation',
    component: Layout,
    name: '人才培养',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('talentCultivation/index'),
        name: '人才培养',
        children: [
          {
            path: '/talentCultivation/scheme',
            component: _import('talentCultivation/components/scheme'),
            name: '人才培养方案'
          },
          {
            path: '/talentCultivation/teacher',
            component: _import('talentCultivation/components/teacher'),
            name: '教员队伍方案'
          },
          {
            path: '/talentCultivation/result',
            component: _import('talentCultivation/components/result'),
            name: '教学成果方案'
          },
          {
            path: '/talentCultivation/reformation',
            component: _import('talentCultivation/components/reformation'),
            name: '教学改革方案'
          }
        ]
      }
    ]
  },
  {
    path: '/academicResearch',
    component: Layout,
    name: '学术研究',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('academicResearch/index'),
        name: '学术研究',
        children: [
          {
            path: '/academicResearch/subjects',
            component: _import('academicResearch/components/subjects'),
            name: '研究科目'
          },
          {
            path: '/academicResearch/subjectsDetails',
            component: _import('academicResearch/components/subjectsDetails'),
            name: '研究科目'
          },
          {
            path: '/academicResearch/result',
            component: _import('academicResearch/components/result'),
            name: '研究成果'
          },
          {
            path: '/academicResearch/resultDetails',
            component: _import('academicResearch/components/resultDetails'),
            name: '研究成果'
          }
        ]
      }
    ]
  },
  {
    path: '/teacherTeam',
    component: Layout,
    name: '师资队伍',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('teacherTeam/index'),
        name: '师资队伍',
        children: [
          {
            path: '/teacherTeam/foregoer',
            component: _import('teacherTeam/components/foregoer'),
            name: '学科带头人'
          },
          {
            path: '/teacherTeam/foregoerDetails',
            component: _import('teacherTeam/components/foregoerDetails'),
            name: '学科带头人详情'
          }
        ]
      }
    ]
  },
  {
    path: '/discipline',
    component: Layout,
    name: '学科管理',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('discipline/index'),
        name: '师资队伍',
        children: [
          {
            path: '/discipline/regulatory',
            component: _import('discipline/components/regulatory'),
            name: '教学规章'
          },
          {
            path: '/discipline/regulatoryDetail',
            component: _import('discipline/components/regulatoryDetail'),
            name: '教学规章详情'
          }
        ]
      }
    ]
  },
  {
    path: '/forum',
    component: Layout,
    name: '学科论坛',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('forum/index'),
        name: '学科论坛',
        children: [
          {
            path: '/forum/article',
            component: _import('forum/components/article'),
            name: '文章列表'
          },
          {
            path: '/forum/forumContent',
            component: _import('forum/components/forumContent'),
            name: '论坛'
          },
          {
            path: '/forum/writeArticle',
            component: _import('forum/components/writeArticle'),
            name: '写文章'
          }
        ]
      }
    ]
  },
  {
    path: '/personalCenter',
    component: Layout,
    name: '个人中心',
    noDropdown: true,
    hidden: false,
    children: [
      {
        path: '',
        component: _import('personalCenter/index'),
        name: '个人中心',
        children: [
          {
            path: '/personalCenter/myArticle',
            component: _import('personalCenter/components/myArticle'),
            name: '我的文章'
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

export default new Router({
  // mode: 'hash',
  // mode: 'history',
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap.concat(asyncRouterMap)
})
